package com.xuliucar.car.adapter

import android.annotation.SuppressLint
import android.graphics.Color
import com.cangmaomao.lib.widget.CustomView
import com.cangmaomao.recyclerview.adapter.CMMAdapter
import com.cangmaomao.recyclerview.adapter.CMMViewHolder
import com.xuliucar.car.R
import de.hdodenhof.circleimageview.CircleImageView

/**
 * Author:帅气的potato
 */
class ColorSelectAdapter : CMMAdapter<Int>(R.layout.item_color_select) {

    @SuppressLint("ResourceType")
    override fun convert(holder: CMMViewHolder, color: Int, p2: Int) {
        val imagePlus = holder.getView<CustomView>(R.id.imagePlus)
        imagePlus.setColor(color)
        imagePlus.setOnClickListener{
            if (mColorCall!=null)
                mColorCall!!.selectColor(color)
        }
    }

    fun setColorListener(mColorCall:colorCall){
        this.mColorCall = mColorCall
    }

    var mColorCall:colorCall? = null

    interface colorCall{
        fun selectColor(color:Int?)
    }
}